#!/bin/sh
#
# Nagios plugin to monitor Java JMX
#
RDIR=`dirname $0`
OUTPUT=$(java -cp $RDIR/jmxquery.jar org.nagios.JMXQuery $@)
EXIT_STATUS=$?
STATUS=`echo $OUTPUT`
VALUE=$(echo $OUTPUT | sed 's/.*{\(.*\)}.*/\1;/' | sed 's/;/; /g' | sed 's/JMX OK //g')
echo "$STATUS | $VALUE"

exit $EXIT_STATUS
